Migrate to std::sync::TaskPool
authorAlex Crichton <alex@alexcrichton.com>
Tue, 9 Dec 2014 04:24:27 +0000 (20:24 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 9 Dec 2014 04:24:27 +0000 (20:24 -0800)
No need to have our own bundled implementation when the standard library
suffices!

src/cargo/ops/cargo_rustc/job_queue.rs
src/cargo/util/mod.rs
src/cargo/util/pool.rs [deleted file]

index 735fd165e07dc0a932b621adb5f02692e2526b73..256ee73cd23ea9acc58630b17a852465033ed567 100644 (file)
@@ -1,9 +1,10 @@
 use std::collections::HashSet;
 use std::collections::hash_map::{HashMap, Occupied, Vacant};
+use std::sync::TaskPool;
 use term::color::YELLOW;
 
 use core::{Package, PackageId, Resolve, PackageSet};
-use util::{Config, TaskPool, DependencyQueue, Fresh, Dirty, Freshness};
+use util::{Config, DependencyQueue, Fresh, Dirty, Freshness};
 use util::{CargoResult, Dependency, profile};
 
 use super::job::Job;
index e23ab7dc01fefc79d85afe8de081e6559da1caf7..18daf6d97e3ad8d9afb16d2ca1b05362507c666d 100644 (file)
@@ -6,7 +6,6 @@ pub use self::errors::{CliError, FromError, ProcessError};
 pub use self::errors::{process_error, internal_error, internal, human, caused_human};
 pub use self::paths::{realpath, join_paths};
 pub use self::hex::{to_hex, short_hash};
-pub use self::pool::TaskPool;
 pub use self::dependency_queue::{DependencyQueue, Fresh, Dirty, Freshness};
 pub use self::dependency_queue::Dependency;
 pub use self::graph::Graph;
@@ -28,6 +27,5 @@ pub mod to_semver;
 pub mod to_url;
 pub mod toml;
 mod dependency_queue;
-mod pool;
 mod sha256;
 mod vcs;
diff --git a/src/cargo/util/pool.rs b/src/cargo/util/pool.rs
deleted file mode 100644 (file)
index 1dc2d73..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-//! A load-balancing task pool.
-//!
-//! This differs in implementation from std::sync::TaskPool in that each job is
-//! up for grabs by any of the child tasks in the pool.
-//!
-//! This should be upstreamed at some point.
-
-use std::sync::{Arc, Mutex};
-
-pub struct TaskPool {
-    tx: SyncSender<proc():Send>,
-}
-
-impl TaskPool {
-    pub fn new(tasks: uint) -> TaskPool {
-        assert!(tasks > 0);
-        let (tx, rx) = sync_channel(tasks);
-
-        let state = Arc::new(Mutex::new(rx));
-
-        for _ in range(0, tasks) {
-            let state = state.clone();
-            spawn(proc() worker(&*state));
-        }
-
-        return TaskPool { tx: tx };
-
-        fn worker(rx: &Mutex<Receiver<proc():Send>>) {
-            loop {
-                let job = rx.lock().recv_opt();
-                match job {
-                    Ok(job) => job(),
-                    Err(..) => break,
-                }
-            }
-        }
-    }
-
-    pub fn execute(&self, job: proc():Send) {
-        self.tx.send(job);
-    }
-}